package com.novellotus.iov.carvice.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.novellotus.iov.carvice.R;
import com.novellotus.iov.carvice.activity.ChargeStationDetailActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Rich on 2018/3/9.
 */

public class ChargeListAdapter extends RecyclerView.Adapter<ChargeListAdapter.ItemHolder> {

    Context context;

    @Override
    public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_charge_list, parent, false);
        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemHolder holder, int position) {
        holder.rlt_item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, ChargeStationDetailActivity.class);
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 10;
    }

    class ItemHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.rlt_item)
        RelativeLayout rlt_item;

        ItemHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
